﻿using infoMECHANICA.NHibernateORM.TestMappings;
using NHibernate.Criterion;

namespace infoMECHANICA.NHibernateORM.ExampleProgram
{
    /// <summary>
    /// See http://www.codeplex.com/nhcb/Wiki/View.aspx?title=SUBQUERIES&referringTitle=Home for details
    /// </summary>
    public class Example4 : IExample
    {
        #region IExample Members

        public string Title
        {
            get { return "Example 4 - subqueries"; }
        }

        public DetachedCriteria ComposeCriteria()
        {
            //composing business query
            CountryRec countryRec = new CountryRec();
            countryRec.Region.SetEq("NORTH_AMERICA");

            CompanyRec companyRec = new CompanyRec();
            companyRec.Country.Name.SetEq(countryRec.Name.RecordedProjection);

            return companyRec.BuildCriteria();
        }

        #endregion
    }
}
